import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'video_player_controller.dart';

class VideoPlayerH extends StatelessWidget {
  final VideoPlayerController controller = Get.put(VideoPlayerController());

  VideoPlayerH({super.key});

  @override
  Widget build(BuildContext context) {
    // 进入横屏， 退出竖屏

    // 获取屏幕宽高
    final screenSize = MediaQuery.of(context).size;
    final screenWidth = screenSize.width;
    final screenHeight = screenSize.height;

    return SafeArea(
      child: Container(
        // color: Colors.black,
        child: Stack(
          children: [
            // 布局 三行
            Positioned(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    height: 50,
                    color: Colors.red,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        IconButton(
                          icon: Icon(Icons.arrow_back_ios_sharp, color: Colors.white),
                          onPressed: () {
                            // 返回
                            Navigator.of(context).pop();
                          },
                        ),
                        Text(
                          '影视标题',
                          style: TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                            color: Colors.white,
                          ),
                        ),
                        IconButton(
                          icon: Icon(Icons.more_vert, color: Colors.white),
                          onPressed: () {
                            // 更多
                          },
                        ),
                      ],
                    ),
                  ),
                  Container(
                    child: Text('自定义位置'),
                  ),
                  Container(
                    height:  70,
                    color: Colors.red,
                    child: Column(
                      children: [
                        // 显示进度条， 时间 进度条， 时间
                        SizedBox(width: 20),
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: 20),
                          decoration: BoxDecoration(
                            color: Colors.white30,
                            borderRadius: BorderRadius.circular(4),
                          ),
                          height: 20,
                          width: screenWidth * 0.8,
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Container(
                                child: Text(
                                  '00:00',
                                  style: TextStyle(color: Colors.white, fontSize: 12),
                                ),
                              ),
                              SizedBox(width: 10),
                              Container(
                                // width: double.infinity,
                                child: LinearProgressIndicator(
                                  value: 0.5,
                                  backgroundColor: Colors.white.withOpacity(0.2),
                                  valueColor: AlwaysStoppedAnimation(Colors.blue),
                                ),
                              ),
                              SizedBox(width: 10),
                              Container(
                                width: 150,
                                child: Text(
                                  '02:30',
                                  style: TextStyle(color: Colors.white, fontSize: 12),
                                ),
                              ),
                            ],
                          ),
                        ),


                        // 进度条
                        Container(
                          // height: screenHeight * 0.1,
                          // color: Colors.blue,
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              IconButton(
                                icon: Icon(Icons.play_arrow, color: Colors.white),
                                onPressed: () {
                                  // 播放
                                },
                              ),
                              IconButton(
                                icon: Icon(Icons.fullscreen, color: Colors.white),
                                onPressed: () {
                                  // 全屏
                                  controller.toggleFullScreen();
                                },
                              ),
                              IconButton(
                                icon: Icon(Icons.volume_up, color: Colors.white),
                                onPressed: () {
                                  // 音量
                                },
                              ),
                              IconButton(
                                icon: Icon(Icons.closed_caption, color: Colors.white),
                                onPressed: () {
                                  // 弹幕
                                },
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
